package cn.tedu;

import java.io.File;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        System.out.println("请输入文件夹路径:");
        String s=new Scanner(System.in).nextLine();
        File f=new File(s);
        long a=f.length();
        System.out.println("文件夹:"+s+"的总大小是:"+a);
        z(f);
        z2(f);

    }
    private static long  z(File a) {
        long c = 0;
        File[] b = a.listFiles();
        for (File x : b) {
            if (x.isFile()) {
                c = c + x.length();
            }else if(x.isDirectory()){
                c=c+z(x);
            }
        }
        return c;
    }
    private static void z2(File a){
        File[] b=a.listFiles();
        for(File x:b){
            if(x.isFile()){
                x.delete();
            }else if(x.isDirectory()){
                z2(x);
            }
        }
        a.delete();
    }

}
